﻿using Microsoft.Xna.Framework;

namespace Firefly.Framework.Windows.Forms
{
    public class RadioButton : Checkbox
    {
        protected override void SetChecked(bool value)
        {
            if (_checked != value)
            {
                if (value && Parent != null)
                {
                    foreach (Control c in Parent.Children)
                    {
                        if (c is RadioButton)
                        {
                            if (!(c == this)) ((RadioButton)c).Checked = false;
                        }
                    }
                }

                _checked = value;
                OnCheckecChanged();
            }
        }

        #region IDrawable Members

        public override void Draw(GameTime gameTime)
        {
            if (Visible)
            {
                if (_checked)
                {
                    WindowsService.Instance.Theme.Toggle.Draw("RadioTrue", DrawRectangle, Color);
                }
                else
                {
                    WindowsService.Instance.Theme.Toggle.Draw("RadioFalse", DrawRectangle, Color);
                }

                DrawChildren(gameTime);
            }
        }

        #endregion
    }
}
